define(function(require, exports, module) {
    require('form');
    exports.init = function (config) {
        var fromUrl = config.fromUrl;
        $('#js-login-form').on('submit', function() {
            $('#error').html('');
            $(this).ajaxSubmit({
                url: '/Ajax/Passport/login?stmp=' + new Date().toString(),
                type: 'post',
                dataType: 'json',
                success: function(d) {
                    if (d.error) {
                        $('#error').html(d.data);
                    } else {
                        window.location.href = fromUrl;
                    }
                }
            });
            return false;
        });
    }
});